package sicau.car.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import sicau.car.entity.Application;
import sicau.car.mapper.ApplicationMapper;
import sicau.car.service.ApplicationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ITcz
 * @since 2020-07-28
 */
@Service
public class ApplicationServiceImpl extends ServiceImpl<ApplicationMapper, Application> implements ApplicationService {

    @Autowired
    ApplicationMapper applicationMapper;

    @Override
    public int order(Application applicationInform) {
        int insert = applicationMapper.insert(applicationInform);
        return insert;
    }

    @Override
    public IPage<Application> showOwnOrder(int page, int pageSize, int userId) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        queryWrapper.last("ORDER BY create_time DESC");
        Page<Application> applicationPage = new Page<>(page, pageSize);
        Page page1 = applicationMapper.selectPage(applicationPage, queryWrapper);
        return page1;
    }

}
